namespace Domotica.Windows.Input
{
    using Microsoft.VisualBasic;
    using System;
    using System.ComponentModel;
    using System.Windows.Input;
    using System.Windows.Markup;

    public class SpeechBinding : InputBinding
    {
        public SpeechBinding()
        {
        }

        public SpeechBinding(ICommand command, SpeechGesture gesture) : base(command, gesture)
        {
        }

        internal SpeechBinding(ICommand command, string choiceText) : this(command, new SpeechGesture(choiceText))
        {
        }

        public string ChoiceText
        {
            get
            {
                if (this.Gesture != null)
                {
                    return ((SpeechGesture) this.Gesture).ChoiceText;
                }
                return null;
            }
            set
            {
                if (this.Gesture==null)
                {
                    this.Gesture = new SpeechGesture(value);
                }
                else
                {
                    ((SpeechGesture) this.Gesture).ChoiceText = value;
                }
            }
        }

        [ValueSerializer(typeof(SpeechGestureValueSerializer)), TypeConverter(typeof(SpeechGestureConverter))]
        public override InputGesture Gesture
        {
            get
            {
                return (base.Gesture as SpeechGesture);
            }
            set
            {
                if (!(value is SpeechGesture))
                {
                    throw new ArgumentException("Expected type SpeechGesture");
                }
                base.Gesture = value;
            }
        }
    }
}

